﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Xml.Linq;

namespace Shop.Help
{
    public class DataUtil
    {
        /// <summary>
        /// 根据资源名获得TextReader
        /// </summary>
        /// <param name="resourceName">资源文件名(命名空间+文件名)</param>
        /// <returns>TextReader</returns>
        private static TextReader GetResource(string resourceName)
        {
            Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
            if (stream != null) return new StreamReader(stream);
            return null;
        }

        public static string GetSexStr(string id)
        {
            return XElement.Load(GetResource("BaiMeng.Framework.Utility.Data.Sex.xml")).Elements("Sex").First<XElement>(c => c.Element("ID").Value == id).Element("Name").Value;
        }


      

    }
}
